<template>
<!-- 对话框 -->
  <transition name="slide">
    <div class="modal" v-show="showModal">
      <div class="mask"></div>
      <transition name="slide">
        <div class="modal-dialog" v-show="showModal">
          <div class="modal-header">
            <span>{{title}}</span>
            <span class="icon-close" @click="$emit('cancel')"></span>
          </div>
          <div class="modal-body">
            <slot name="body"></slot>
          </div>
          <div class="modal-footer">
            <a
              href="javascript: ;"
              class="btn" v-if="btnType==='1'"
              @click="$emit('submit')"
            >{{sureText}}</a>
            <a
              href="javascript: ;"
              class="btn btn-default"
              v-if="btnType==='2'"
            >{{cancelText}}</a>
            <div class="btn-group" v-if="btnType === '3'">
              <a href="javascript: ;" class="btn" @click="$emit('submit')">{{sureText}}</a>
              <a href="javascript: ;" class="btn btn-default" @click="$emit('cancel')">{{cancelText}}</a>
            </div>
          </div>
        </div>
      </transition>
    </div>
  </transition>
</template>

<script>
  export default {
    name: 'modal',
    props: {
      modalType: {
        type: String,
        default: 'form'
      },
      title: String,
      sureText: {
        type: String,
        default: '确定'
      },
      cancelText: {
        type: String,
         default: '取消'
      },
      btnType: String, // 1. 确定按钮 2. 取消按钮 3. 确定/取消按钮组
      showModal: Boolean

    }
  }
</script>

<style lang='scss' scoped>
@import '../assets/scss/mixin.scss';
@import '../assets/scss/config.scss';
@import '../assets/scss/button.scss';
@import '../assets/scss/modal.scss';
</style>